Introduction

The VDoc development kit provides a new Framework for implementing new functions used within the documents. This new Framework is very similar to both components and plug-in frameworks. It provides a Java-based plug-in model for functions.

To speed time to market and reduce costs for developers, this new Framework includes a complete API, libraries and samples that illustrate reference implementation for successful custom functions.

This topic provides information about VDoc development kit and how you can create custom functions to enhance your documents.

What is a function ?

A function is a small unit of process which transforms data to a particular output. Functions are used in several contexts :

  • initializing field values
  • showing or hiding graphical elements through the fragments
  • defining a test
  • and defining a view filter

Basically, a function is composed of a name, arguments and a method called execute. The return type is a java.lang.Object.

The function Framework gives a standard way for defining :

  • an XML definition file: an association between the name of the function and its class (full qualified name).
  • a function class: class to execute while evaluating the functions.
  • an XML resource file: localized string.

XML definition

The XML function file should be deployed on the custom/functions folder. Its name must be unique on the VDoc server. To prevent name conflicts it is recommended to use the following template: companyName-functions.xml (e.i. vdoc-functions.xml). This XML definition file provides all the necessary information to describe several functions:

  • Function name: The name should be unique on the VDoc server and in upper case.
    Error during retrieving content skip as ignoreDownloadError activated.
  • Function runtime class: The full qualified name of the function class to execute.
  • Function category: The category is optional. If not declared, the function will appear inside a default category.
  • argument tags: allows to specify the default values for the optional arguments. Use the zero-based index to target an argument.

Runtime class

A runtime class is a Java class which will be called by the framework. A runtime class must extend the Open Declaration com.axemble.vdoc.sdk.BaseFormulaFunction class.

By creating a function runtime class you need to implement a unique method: execute().

Create the runtime class for the validator

/**
  Example : 
*/
public class TranslateFunction extends BaseFormulaFunction
{
        private static final long serialVersionUID = 1L;

        public String execute( String id, String... args )
        {
                String language = (String)getContextValue( "language" ); // retrieve the language
                return LocalizationMap.getString( id, language, args );
        }
}

XML resource

In order to localize the name of the function, you should always specify each string as a resource. The XML resource file should be deployed on the custom/internationalization folder. Its name must be unique on the VDoc server. To prevent name conflicts it is recommended to use the following template: companyName-functions-resources.xml (e.i. vdoc-functions-resources.xml). This file must contain every string used for the treatment.

Use the ids as shown in the following exemple:

Error during retrieving content skip as ignoreDownloadError activated.

Define a category

In order to define new categories, you can deploy an XML file on the custom/global folder. To prevent name conflicts it is recommended to use the following template: companyName-global.xml (e.i. vdoc-global.xml).

<definitions>
        <function>
                <categories>
                        <category name="mycategory" label="formula.function.category.mycategory.label" description="formula.function.category.mycategory.description"/>
                </categories>
        </function>
</definitions>